package com.helisa;


import android.app.Activity;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TabHost;

public class PruebaActivity extends Activity {

	DialogInterface.OnClickListener onClickListenerYes = new DialogInterface.OnClickListener() {
		
		@Override
		public void onClick(DialogInterface dialog, int which) {
			
			
		}
	};
	
	
	DialogInterface.OnClickListener onClickListenerNo = new DialogInterface.OnClickListener() {
		
		public void onClick(DialogInterface dialog, int which) {
			
			
		}
	};
	
	private EditText usu;
	private EditText pass;
	private Alerts popup;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		darFuncionTabs();
	
		
		
		usu = (EditText) findViewById(R.id.editText1);
		pass = (EditText) findViewById(R.id.editText2);

		Button btnEntrar = (Button) findViewById(R.id.button1);
		btnEntrar.setOnClickListener(l);
		
		Button btnLimpiar = (Button) findViewById(R.id.button2);
		btnLimpiar.setOnClickListener(l2);
		
		Button btnVerificarConexion = (Button) findViewById(R.id.button3);
		btnVerificarConexion.setOnClickListener(l3);
		
		Button btnLlamarServicio = (Button) findViewById(R.id.button4);
		btnLlamarServicio.setOnClickListener(l4 );
	}

	private void darFuncionTabs() {
		Resources res = getResources();

		TabHost tabs=(TabHost)findViewById(android.R.id.tabhost);
		tabs.setup();

		TabHost.TabSpec spec=tabs.newTabSpec("mitab1");
		spec.setContent(R.id.tab1);
		spec.setIndicator("TAB1",
				res.getDrawable(android.R.drawable.ic_btn_speak_now));
		tabs.addTab(spec);

		spec=tabs.newTabSpec("mitab2");
		spec.setContent(R.id.tab2);
		spec.setIndicator("TAB2",
				res.getDrawable(android.R.drawable.ic_dialog_map));
		tabs.addTab(spec);
		
		spec=tabs.newTabSpec("mitab3");
		spec.setContent(R.id.tab3);
		spec.setIndicator("TAB3",
				res.getDrawable(android.R.drawable.ic_dialog_map));
		tabs.addTab(spec);

		tabs.setCurrentTab(0);

	}
	
	OnClickListener l = new OnClickListener() {
		
		public void onClick(View v) 
		{
			usu.getEditableText().toString();
			if( usu.getText().toString().equals("") || pass.getText().toString().equals("") ){
//				popup.createAlertDialogOk(PruebaActivity.this, null, "Ponga Daticos");
			}else{
//				popup.createAlertDialogOk(PruebaActivity.this, "Exito", "Ingreso");
			}
		}
	};
	
	OnClickListener l2 = new OnClickListener() 
	{
		public void onClick(View v) 
		{
			usu.setText("");
			pass.setText("");
		}
	};
	OnClickListener l3 = new OnClickListener() {

		@SuppressWarnings("static-access")
		public void onClick(View arg0) {
			String msn = CheckConnection.hasInternetByType(PruebaActivity.this);
			if(CheckConnection.hasConnection(PruebaActivity.this)){
				popup.createInformationDialog(PruebaActivity.this, null, "El dispositivo esta conectado");
				popup.createInformationDialog(PruebaActivity.this, "Conexiones", msn);
			}
			else{
				popup.createInformationDialog(PruebaActivity.this, null, "No hay conexiones disponibles");
			}
		}
	};
	
	private OnClickListener l4 = new OnClickListener() {
		public void onClick(View arg0) {
			Alerts.createProgressDialog(PruebaActivity.this, null, "Cargando", true,new RunnableProgress() {
				public void runModified() {
					try {
						Thread.sleep(5000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			});
			
		}
	};
}